﻿Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
''' <summary>
''' Wichtiges Steuerelemt in welchem Buttons und andere Tools angeordnet werden können.
''' </summary>
''' <remarks></remarks>
Public Class ObjektBox
    Dim Buttons As ObjektButton() = {}
    Public NUDS As ObjektNumericUpDown() = {}
    Public SUDS As ObjektStringUpDown() = {}
    Public Labels As ObjektLabel() = {}
    Dim Rechteck As Rectangle
    Dim HintergrundsID As Integer
    Public Zustand As Zustände
    Enum Zustände
        ''' <summary>
        ''' Gibt an das die Box da ist aber alle Befehle ausgeführt werden
        ''' </summary>
        ''' <remarks></remarks>
        Keiner
        ''' <summary>
        ''' Gibt an das nur die Box Befehle von der Form ausgeführt werden
        ''' </summary>
        ''' <remarks></remarks>
        NurBefehle
        ''' <summary>
        ''' Gibt an das die Box bei einem Befehl beendet wird
        ''' </summary>
        ''' <remarks></remarks>
        Abrechen
    End Enum
    Public Sub New(ByVal neuZustand As Zustände, ByVal neuButtons As ObjektButton(), ByVal neuNUDS As ObjektNumericUpDown(), ByVal neuSUDS As ObjektStringUpDown(), ByVal neuLabels As ObjektLabel(), ByVal neuRechteck As Rectangle, ByVal neuHintergrund As Integer)
        Zustand = neuZustand
        Buttons = neuButtons
        NUDS = neuNUDS
        SUDS = neuSUDS
        Labels = neuLabels
        Rechteck = neuRechteck
        HintergrundsID = neuHintergrund
    End Sub
    Public Function MouseUp(ByVal X As Integer, ByVal Y As Integer) As String
        Dim Funktion As String = ""
        For I = 0 To Buttons.Length - 1
            Dim F As String = Buttons(I).MouseUp(X, Y)
            If Not F = "" Then
                Return F
            End If
        Next
        For I = 0 To NUDS.Length - 1
            NUDS(I).MouseUp(X, Y)
        Next
        For I = 0 To SUDS.Length - 1
            SUDS(I).MouseUp(X, Y)
        Next
        Return Funktion
    End Function
    Public Sub MouseMove(ByVal X As Integer, ByVal Y As Integer)
        For I = 0 To Buttons.Length - 1
            Buttons(I).MouseEnter(X, Y)
        Next
    End Sub
    Public Sub MouseDown(ByVal X As Integer, ByVal Y As Integer)
        For I = 0 To Buttons.Length - 1
            Buttons(I).MouseDown(X, Y)
        Next
        For I = 0 To NUDS.Length - 1
            NUDS(I).MouseDown(X, Y)
        Next
        For I = 0 To SUDS.Length - 1
            SUDS(I).MouseDown(X, Y)
        Next
    End Sub
    Public Sub Malen()
        Dim sngRotation As Double = 0
        Dim intColor As Color = Color.FromArgb(180, 255, 255, 255)
        Grafikengine.DrawBox(TexturenHalter.GetBoxHintergrund(HintergrundsID), New Point(Rechteck.X, Rechteck.Y), New Size(144, 145), Rechteck.Size, 5, intColor)
        For I = 0 To Labels.Length - 1
            Labels(I).Malen()
        Next
        For I = 0 To Buttons.Length - 1
            Buttons(I).Malen()
        Next
        For I = 0 To NUDS.Length - 1
            NUDS(I).Malen()
        Next
        For I = 0 To SUDS.Length - 1
            SUDS(I).Malen()
        Next
    End Sub
    Public Sub ChangeWindowSize(ByVal PosChange As System.Drawing.Point)
        Rechteck.X += PosChange.X
        Rechteck.Y += PosChange.Y
        For Each Knopf In Buttons
            Knopf.ChangeWindowSize(PosChange)
        Next
        For Each NUD In NUDS
            NUD.ChangeWindowSize(PosChange)
        Next
        For Each SUD In SUDS
            SUD.ChangeWindowSize(PosChange)
        Next
        For Each Label In Labels
            Label.ChangeWindowSize(PosChange)
        Next
    End Sub
End Class
